package com.gpframework.common.enums;

import com.gpframework.common.utils.StringUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 支付枚举
 *
 * @author BrinedFish
 * @create 2022-04-24 15:46
 */
@Getter
@Slf4j
public enum PayEnum {

    // 支付方式
    CASH("现金", "10"),
    ZFB("支付宝", "20"),
    WECHAT("微信支付", "30"),
    OTHER("其它", "40"),
    STORED("储值支付", "50"),
    INTEGRAL("积分支付", "60"),

    // 支付类型
    FULL_PAYMENT("全款支付", "10"),
    INSTALLMENT_PAYMENT("分期支付", "20"),

    // 乐刷订单状态
    STATUS_IN_PAYMENT("支付中", "0"),
    STATUS_PAYMENT_SUCCESSFUL("支付成功", "2"),
    STATUS_ORDER_CLOSING("订单关闭", "6"),
    STATUS_PAYMENT_FAILURE("支付失败", "8"),
    STATUS_IN_REFUND("退款中", "10"),
    STATUS_REFUND_SUCCESSFUL("退款成功", "11"),
    STATUS_REFUND_FAILURE("退款失败", "12"),

    // 乐刷支付类型
    ZFBZF("支付宝支付", "ZFBZF"),
    WXZF("微信支付", "WXZF"),

    //商户进件审核状态
    REJECTED("退回", "REJECTED"),
    REVIEW("待人工检查", "REVIEW"),
    PASSED("通过", "PASSED"),
    UNKNOWN("未知", "UNKNOWN"),
    ADD_INFO("待完善资料", "ADD_INFO"),
    AUDITING("待审核", "AUDITING"),

    // 支付端
    ADMIN_OR_PLATFORM("后台", "10"),
    API("小程序", "20"),


    ;

    /**
     * 业务名称
     */
    private String name;

    private String key;

    private PayEnum() {
    }

    private PayEnum(String name) {
        this.name = name;
    }

    private PayEnum(String name, String key) {
        this.name = name;
        this.key = key;
    }

    public static String getPayEnumCN(String payEnum) {
        if (StringUtils.isEmpty(payEnum)) {
            return payEnum;
        }
        //去除前后空格
        payEnum = payEnum.trim().trim();
        for (PayEnum value : PayEnum.values()) {
            if (value.getKey().equals(payEnum)) {
                return value.getName();
            }
        }
        return payEnum;
    }

    public static String getPayType(String payEnum) {
        if (StringUtils.isEmpty(payEnum)) {
            return payEnum;
        }
        //去除前后空格
        payEnum = payEnum.trim().trim();
        if (payEnum.equals(PayEnum.CASH.getKey())) {
            return PayEnum.CASH.getName();
        }
        if (payEnum.equals(PayEnum.ZFB.getKey())) {
            return PayEnum.ZFB.getName();
        }
        if (payEnum.equals(PayEnum.WECHAT.getKey())) {
            return PayEnum.WECHAT.getName();
        }
        if (payEnum.equals(PayEnum.OTHER.getKey())) {
            return PayEnum.OTHER.getName();
        }
        if (payEnum.equals(PayEnum.STORED.getKey())) {
            return PayEnum.STORED.getName();
        }
        if (payEnum.equals(PayEnum.INTEGRAL.getKey())) {
            return PayEnum.INTEGRAL.getName();
        }
        return payEnum;
    }

    public static String getPayMethod(String payEnum) {
        if (StringUtils.isEmpty(payEnum)) {
            return payEnum;
        }
        //去除前后空格
        payEnum = payEnum.trim().trim();
        if (payEnum.equals(PayEnum.FULL_PAYMENT.getKey())) {
            return PayEnum.FULL_PAYMENT.getName();
        }
        if (payEnum.equals(PayEnum.INSTALLMENT_PAYMENT.getKey())) {
            return PayEnum.INSTALLMENT_PAYMENT.getName();
        }
        return payEnum;
    }
}
